package ai.people.netmon.framework.domain.archives.vo;

import ai.people.netmon.utils.CharPool;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.people.core.validator.annotation.CompareValid;
import com.people.core.validator.annotation.NumberStatusValue;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.logging.log4j.util.Strings;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 添加档案VO
 *
 * @author zhenglin
 * @since 2022/3/30
 */
@Data
@NoArgsConstructor
public class ArchivesAddVO {

    /**
     * 姓名
     */
    private List<String> names;

    /**
     * 性别 0:未知, 1:男 ,2:女
     *
     * @mock 1
     */
    @NumberStatusValue(values = {0, 1, 2}, message = "性别值只能为0,1,2")
    private Integer gender;

    /**
     * 照片
     */
    private String picture;

    /**
     * 出生日期
     */
    private String birthday;

    /**
     * 体重
     */
    @CompareValid(compare = CompareValid.Compare.GT, message = "体重应大于{value}")
    private Double weight;

    /**
     * 身高
     */
    @CompareValid( compare = CompareValid.Compare.GT, message = "身高应大于{value}")
    private Double height;

    /**
     * 籍贯
     */
    @Length(max = 255, message = "籍贯长度最长为{max}")
    private String hometown;

    /**
     * 现居地
     */
    @Length(max = 255, message = "现居地长度最长为{max}")
    private String residentialAddress;

    /**
     * 爱好
     */
    private String hobby;

    /**
     * 身份证
     *
     * @mock 121000000000000000
     */
    @Length(max = 255, message = "身份证长度最长为{max}")
    private String idNumber;

    /**
     * 护照
     */
    private String passport;

    /**
     * 手机号
     */
    private List<String> phoneNumbers;

    /**
     * 车牌号
     */
    private List<String> plateNumbers;

    /**
     * 标签
     */
    private List<String> tags;

    /**
     * 银行账号
     */
    @Valid
    private List<ArchivesVO.Bank> bankAccounts;

    /**
     * 教育经历
     */
    @Valid
    private List<ArchivesVO.Education> educationExperiences;

    /**
     * 就业经历
     */
    @Valid
    private List<ArchivesVO.Work> workExperiences;

    /**
     * 政治立场
     */
    private String political;

    /**
     * 家庭信息
     */
    private String familySituation;

    /**
     * 个人信息
     */
    private String personalSituation;

    /**
     * 档案研判
     */
    private String archivesJudgment;

    /**
     * 备注
     */
    private String note;

    /**
     * 创建人
     */
    private String creator;

    /**
     * 创建时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    /**
     * 公司信息列表
     */
    @Valid
    ArchivesVO.CompanyInfo companyInfo;

    /**
     * 社交媒体
     */
    @Valid
    ArchivesVO.SocialInfo socialInfo;

    public String namesStr() {
        return getString(this.names);
    }

    private static String getString(List<String> list) {
        if (CollectionUtils.isNotEmpty(list)) {
            return Strings.join(list, CharPool.COMMA);
        }
        return null;
    }

    private static <T> String getJsonString(List<T> list) {
        if (CollectionUtils.isNotEmpty(list)) {
            return JSONObject.toJSONString(list);
        }
        return null;
    }


    public String phoneNumbersStr() {
        return getString(this.phoneNumbers);
    }


    public String plateNumbersStr() {
        return getString(this.plateNumbers);
    }


    public String tagsStr() {
        return getString(this.tags);
    }


    public String bankAccountsJson() {
        return getJsonString(this.bankAccounts);
    }


    public String educationExperiencesJson() {
        return getJsonString(this.educationExperiences);
    }


    public String workExperiencesJson() {
        return getJsonString(this.workExperiences);
    }


}
